Skip to content

,System.IObservable{System.Collections.IEnumerable}})} ,System.IObservable{System.Collections.IEnumerable}},System.Boolean)} ,System.IObservable{System.String}})} ,System.IObservable{System.String}},System.Boolean)} })} },System.Boolean)} })} },System.Boolean)} )} ,System.Boolean)} )} ,System.Boolean)}

ReactiveProperty.AddValidationError(Func, IObservable>) method

Defined in

Type: ReactiveProperty Namespace: ReactiveUI.Reactive Assembly: ReactiveUI.Reactive.dll

Applies to

net10.0, net10.0-maccatalyst26.0, net10.0-desktop1.0, net10.0-browserwasm1.0, net10.0-tvos26.0, net10.0-windows10.0.19041, net10.0-macos26.0, net10.0-ios26.0, net10.0-android36.0, net9.0, net9.0-tvos18.0, net9.0-macos15.0, net9.0-maccatalyst18.0, net9.0-windows10.0.19041, net9.0-ios18.0, net9.0-desktop1.0, net8.0, net8.0-windows10.0.19041, net8.0-ios18.0, net8.0-maccatalyst18.0, net8.0-macos15.0, net8.0-tvos18.0, net8.0-ios17.5, net8.0-maccatalyst17.5, net8.0-macos14.5, netstandard2.1, net481, net462, net471

Overloads

  • 1. public ReactiveProperty<T> AddValidationError(Func<IObservable<T?>, IObservable<IEnumerable?>> validator)
  • 2. public ReactiveProperty<T> AddValidationError(Func<IObservable<T?>, IObservable<IEnumerable?>> validator, bool ignoreInitialError)
  • 3. public ReactiveProperty<T> AddValidationError(Func<IObservable<T?>, IObservable<string?>> validator)
  • 4. public ReactiveProperty<T> AddValidationError(Func<IObservable<T?>, IObservable<string?>> validator, bool ignoreInitialError)
  • 5. public ReactiveProperty<T> AddValidationError(Func<T?, Task<IEnumerable?>> validator)
  • 6. public ReactiveProperty<T> AddValidationError(Func<T?, Task<IEnumerable?>> validator, bool ignoreInitialError)
  • 7. public ReactiveProperty<T> AddValidationError(Func<T?, Task<string?>> validator)
  • 8. public ReactiveProperty<T> AddValidationError(Func<T?, Task<string?>> validator, bool ignoreInitialError)
  • 9. public ReactiveProperty<T> AddValidationError(Func<T?, IEnumerable?> validator)
  • 10. public ReactiveProperty<T> AddValidationError(Func<T?, IEnumerable?> validator, bool ignoreInitialError)
  • 11. public ReactiveProperty<T> AddValidationError(Func<T?, string?> validator)
  • 12. public ReactiveProperty<T> AddValidationError(Func<T?, string?> validator, bool ignoreInitialError)

1. Overload

public ReactiveProperty<T> AddValidationError(Func<IObservable<T?>, IObservable<IEnumerable?>> validator)

View source

Summary: Adds a validation rule to the current ReactiveProperty instance using the specified validator function.

Parameters

NameTypeDescription
validatorFunc, IObservable>A function that takes an observable sequence of property values and returns an observable sequence of validation errors.

Returns: ReactiveProperty -- The current ReactiveProperty instance with the added validation rule.

2. Overload

public ReactiveProperty<T> AddValidationError(Func<IObservable<T?>, IObservable<IEnumerable?>> validator, bool ignoreInitialError)

View source

Summary: Adds a validation rule to the current ReactiveProperty instance using the specified validator function.

Parameters

NameTypeDescription
validatorFunc, IObservable>A function that takes an observable sequence of property values and returns an observable sequence of validation errors. The returned sequence should emit validation results whenever the property value changes.
ignoreInitialErrorbooltrue to ignore validation for the initial value of the property; otherwise, false. If true, validation will only occur on subsequent value changes.

Returns: ReactiveProperty -- The current ReactiveProperty instance with the added validation rule.

Remarks

Multiple validation rules can be added by calling this method multiple times. Validation errors from all registered validators are combined. The ErrorsChanged event is raised whenever the set of validation errors changes.

3. Overload

public ReactiveProperty<T> AddValidationError(Func<IObservable<T?>, IObservable<string?>> validator)

View source

Summary: Adds a validation rule to the property using the specified validator function.

Parameters

NameTypeDescription
validatorFunc, IObservable>A function that receives an observable sequence of property values and returns an observable sequence of validation error messages.

Returns: ReactiveProperty -- The current ReactiveProperty instance with the validation rule applied.

4. Overload

public ReactiveProperty<T> AddValidationError(Func<IObservable<T?>, IObservable<string?>> validator, bool ignoreInitialError)

View source

Summary: Adds a validation rule to the property using the specified validator function.

Parameters

NameTypeDescription
validatorFunc, IObservable>A function that receives an observable sequence of property values and returns an observable sequence of validation error messages. The returned string is interpreted as the error message; a null value indicates no error.
ignoreInitialErrorbooltrue to suppress the initial validation error until the property value changes; otherwise, false.

Returns: ReactiveProperty -- The current ReactiveProperty instance with the validation rule applied.

Remarks

Multiple validation rules can be added by calling this method multiple times. Validation errors are aggregated and exposed by the property. The validator function should be stateless and thread-safe.

5. Overload

public ReactiveProperty<T> AddValidationError(Func<T?, Task<IEnumerable?>> validator)

View source

Summary: Adds asynchronous validation logic to the reactive property using the specified validator function.

Parameters

NameTypeDescription
validatorFunc>A function that asynchronously validates the current value and returns a collection of validation errors.

Returns: ReactiveProperty -- The current ReactiveProperty instance with the specified validation logic applied.

6. Overload

public ReactiveProperty<T> AddValidationError(Func<T?, Task<IEnumerable?>> validator, bool ignoreInitialError)

View source

Summary: Adds asynchronous validation logic to the reactive property using the specified validator function.

Parameters

NameTypeDescription
validatorFunc>A function that asynchronously validates the current value and returns a collection of validation errors. The function receives the current value as input and returns a task that produces an enumerable of validation error objects. If the collection is empty or null, the value is considered valid.
ignoreInitialErrorbooltrue to suppress validation errors for the initial value; otherwise, false.

Returns: ReactiveProperty -- The current ReactiveProperty instance with the specified validation logic applied.

Remarks

This method enables chaining of multiple validation rules on a ReactiveProperty. Validation is triggered whenever the property's value changes. The validator function can perform asynchronous operations, such as remote checks or complex computations.

7. Overload

public ReactiveProperty<T> AddValidationError(Func<T?, Task<string?>> validator)

View source

Summary: Adds an asynchronous validation rule to the property using the specified validator function.

Parameters

NameTypeDescription
validatorFunc>A function that asynchronously validates the property's value and returns an error message or null.

Returns: ReactiveProperty -- The current ReactiveProperty instance with the validation rule applied.

8. Overload

public ReactiveProperty<T> AddValidationError(Func<T?, Task<string?>> validator, bool ignoreInitialError)

View source

Summary: Adds an asynchronous validation rule to the property using the specified validator function.

Parameters

NameTypeDescription
validatorFunc>A function that asynchronously validates the property's value and returns an error message if validation fails, or null if the value is valid.
ignoreInitialErrorbooltrue to suppress the initial validation error until the value changes; otherwise, false.

Returns: ReactiveProperty -- The current ReactiveProperty instance with the validation rule applied.

Remarks

The validator function is invoked whenever the property's value changes. If multiple validation rules are added, all are evaluated and their error messages are aggregated.

9. Overload

public ReactiveProperty<T> AddValidationError(Func<T?, IEnumerable?> validator)

View source

Summary: Adds a validation rule to the reactive property using the specified validator function.

Parameters

NameTypeDescription
validatorFuncA function that takes the current value and returns a collection of validation errors.

Returns: ReactiveProperty -- The current ReactiveProperty instance with the validation rule applied.

10. Overload

public ReactiveProperty<T> AddValidationError(Func<T?, IEnumerable?> validator, bool ignoreInitialError)

View source

Summary: Adds a validation rule to the reactive property using the specified validator function.

Parameters

NameTypeDescription
validatorFuncA function that takes the current value and returns a collection of validation errors. Returns null or an empty collection if the value is valid.
ignoreInitialErrorbooltrue to ignore validation errors for the initial value; otherwise, false.

Returns: ReactiveProperty -- The current ReactiveProperty instance with the validation rule applied.

Remarks

If multiple validation rules are added, all validators are evaluated and their errors are aggregated. The validator function is invoked whenever the property's value changes.

11. Overload

public ReactiveProperty<T> AddValidationError(Func<T?, string?> validator)

View source

Summary: Adds a validation rule to the property using the specified validator function.

Parameters

NameTypeDescription
validatorFuncA function that returns a validation error message or null if the value is valid.

Returns: ReactiveProperty -- The current ReactiveProperty instance with the validation rule applied.

12. Overload

public ReactiveProperty<T> AddValidationError(Func<T?, string?> validator, bool ignoreInitialError)

View source

Summary: Adds a validation rule to the property using the specified validator function.

Parameters

NameTypeDescription
validatorFuncA function that takes the current value of the property and returns a validation error message if the value is invalid; otherwise, returns null or an empty string if the value is valid.
ignoreInitialErrorbooltrue to suppress validation errors for the initial value of the property; otherwise, false.

Returns: ReactiveProperty -- The current ReactiveProperty instance with the validation rule applied.

Remarks

If multiple validation rules are added, all validators are evaluated and their error messages are aggregated. The property is considered valid only if all validators return null or an empty string.